package com.wilmer.aiUserMsg.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wilmer.common.annotation.Log;
import com.wilmer.common.core.controller.BaseController;
import com.wilmer.common.core.domain.AjaxResult;
import com.wilmer.common.enums.BusinessType;
import com.wilmer.aiUserMsg.domain.YwUserMsg;
import com.wilmer.aiUserMsg.service.IYwUserMsgService;
import com.wilmer.common.utils.poi.ExcelUtil;
import com.wilmer.common.core.page.TableDataInfo;

/**
 * 对话信息Controller
 *
 * @author hans
 * @date 2024-05-15
 */
@Api(tags = {"对话信息接口"})
@RestController
@RequestMapping("/aiUserMsg/aiUserMsg")
public class YwUserMsgController extends BaseController
{
    @Autowired
    private IYwUserMsgService ywUserMsgService;

    /**
     * 查询对话信息列表
     */
    @ApiOperation("查询对话信息列表")
    @PreAuthorize("@ss.hasPermi('aiUserMsg:aiUserMsg:list')")
    @GetMapping("/list")
    public TableDataInfo list(YwUserMsg ywUserMsg)
    {
        startPage();
        List<YwUserMsg> list = ywUserMsgService.selectYwUserMsgList(ywUserMsg);
        return getDataTable(list);
    }

    /**
     * 导出对话信息列表
     */
    @ApiOperation("导出对话信息列表")
    @PreAuthorize("@ss.hasPermi('aiUserMsg:aiUserMsg:export')")
    @Log(title = "对话信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YwUserMsg ywUserMsg)
    {
        List<YwUserMsg> list = ywUserMsgService.selectYwUserMsgList(ywUserMsg);
        ExcelUtil<YwUserMsg> util = new ExcelUtil<YwUserMsg>(YwUserMsg.class);
        util.exportExcel(response, list, "对话信息数据");
    }

    /**
     * 获取对话信息详细信息
     */
    @ApiOperation("获取对话信息详细信息")
    @PreAuthorize("@ss.hasPermi('aiUserMsg:aiUserMsg:query')")
    @GetMapping(value = "/{msgId}")
    public AjaxResult getInfo(@PathVariable("msgId") Long msgId)
    {
        return success(ywUserMsgService.selectYwUserMsgByMsgId(msgId));
    }

    /**
     * 新增对话信息
     */
    @ApiOperation("新增对话信息")
    @PreAuthorize("@ss.hasPermi('aiUserMsg:aiUserMsg:add')")
    @Log(title = "对话信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YwUserMsg ywUserMsg)
    {
        return toAjax(ywUserMsgService.insertYwUserMsg(ywUserMsg));
    }

    /**
     * 修改对话信息
     */
    @ApiOperation("修改对话信息")
    @PreAuthorize("@ss.hasPermi('aiUserMsg:aiUserMsg:edit')")
    @Log(title = "对话信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YwUserMsg ywUserMsg)
    {
        return toAjax(ywUserMsgService.updateYwUserMsg(ywUserMsg));
    }

    /**
     * 删除对话信息
     */
    @ApiOperation("删除对话信息")
    @PreAuthorize("@ss.hasPermi('aiUserMsg:aiUserMsg:remove')")
    @Log(title = "对话信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{msgIds}")
    public AjaxResult remove(@PathVariable Long[] msgIds)
    {
        return toAjax(ywUserMsgService.deleteYwUserMsgByMsgIds(msgIds));
    }
}
